#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main() {
    int arr1[100][100] = { 0 }, arr2[100][100] = { 0 };
    int i = 0, j = 0, n = 0, m = 0;
    scanf("%d %d", &m, &n);
    for (i = 0; i < m; i++)
    {
        for (j = 0; j < n; j++)
        {
            scanf("%d", &arr1[i][j]);
        }
    }
    for (i = 0; i < m; i++)
    {
        for (j = 0; j < n; j++)
        {
            scanf("%d", &arr2[i][j]);
        }
    }
    int c = 0;
    for (i = 0; i < m; i++)
    {
        for (j = 0; j < n; j++)
        {
            if (arr1[i][j] == arr2[i][j])
            {
                c++;
            }
        }
    }
    float k = (float)c / ((float)m * (float)n);
    printf("%.2f", k * 100);
    return 0;
} 